package com.ganinfo.sys.service.impl;


import org.beetl.sql.core.SQLManager;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ganinfo.common.data.TransmitMap;

import com.ganinfo.sys.mapper.SysRolePermissionMapper;
import com.ganinfo.sys.model.SysRolePermission;
import com.ganinfo.sys.service.ISysRolePermissionService;


/**
 * @ClassName:   SysRolePermissionServiceImpl
 * @Description: [sys_role_permission]业务接口实现类
 * @author:      ruikanwang
 * @date:       
 */
@Service
public class SysRolePermissionServiceImpl implements ISysRolePermissionService {
	@Autowired
	SysRolePermissionMapper dao; // mapper

	@Autowired
	SQLManager sql;

	@Override
	public PageQuery<Object> getSysRolePermissionList(TransmitMap transmitMap) {
		PageQuery<Object> pageQuery = new PageQuery<>();
		if(transmitMap.get("orderby")==null){
			//pageQuery.setOrderBy("id desc");
		}else{
			pageQuery.setOrderBy(transmitMap.getString("orderby")+" "+transmitMap.getString("orderbymethod"));
		}
		pageQuery.setPageSize(Integer.parseInt(transmitMap.get("pageSize").toString()));
		pageQuery.setPageNumber(Integer.parseInt(transmitMap.get("pageNumber").toString()));
		pageQuery.setParas(transmitMap);
		sql.pageQuery("sysRolePermission.getSysRolePermissionListByPage", TransmitMap.class, pageQuery);
		return pageQuery;
	}

	@Override
	public boolean addSysRolePermission(SysRolePermission paramSysRolePermission) {
		dao.insertTemplate(paramSysRolePermission);
		return true;
	}

	@Override
	public boolean updateSysRolePermission(SysRolePermission paramSysRolePermission) {
		if(dao.updateTemplateById(paramSysRolePermission)!=-1){
			return true;
		}
		return false;
	}

	@Override
	public boolean deleteSysRolePermission(SysRolePermission paramSysRolePermission) {
		if(dao.deleteById(paramSysRolePermission.getId())!=-1){
			return true;
		}
		return false;
	}



}